package com.huike.business.service.impl;


import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.clues.domain.vo.recordListVO;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.common.utils.SecurityUtils;
import com.huike.common.utils.bean.BeanUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 *
 * @author wgl
 * @date 2021-04-28
 */
@Service
@RequiredArgsConstructor
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {
    private final TbClueTrackRecordMapper tbClueTrackRecordMapper;

    @Override
    public List<recordListVO> list(Integer clueId) {
        return tbClueTrackRecordMapper.selectList(clueId);
    }

    @Override
    public void add(BusinessTrackVo businessTrackVo) {
        String name = businessTrackVo.getName();
        String phone = businessTrackVo.getPhone();
        Integer clueId = tbClueTrackRecordMapper.selectByNameAndPhone(name,phone);
        String nextTime = businessTrackVo.getNextTime().toString();
        recordListVO recordList = new recordListVO();
        BeanUtils.copyBeanProp(recordList,businessTrackVo);
        recordList.setClueId(clueId);
        recordList.setType("1");
        recordList.setCreateBy(SecurityUtils.getUsername());
        recordList.setNextTime(nextTime);
        tbClueTrackRecordMapper.addBusinessTrack(recordList);
    }
}
